﻿@page
@{
    ViewData["Title"] = "Data Sources";
}

<div id="wrapper">
    <div class="container">
        <section id="top" class="section docs-heading"></section>
        <!-- end section -->
        <div class="row">
            <div class="col-md-3">
                <nav class="docs-sidebar" data-spy="affix" data-offset-top="100" data-offset-bottom="200" role="navigation">
                    <ul class="nav">
                        <li><a href="#lineConnections">Connections</a></li>
                        <li>
                            <a href="#lineTables">Tables and Columns</a>
                            <ul class="nav">
                                <li><a href="#lineTables_pps">Pre and Post SQL</a></li>
                                <li><a href="#lineTables_wc">WHERE Clause</a></li>
                                <li><a href="#lineTables_cr">Common Restrictions</a></li>
                            </ul>
                        </li>
                        <li>
                            <a href="#lineColumns">Columns</a>
                            <ul class="nav">
                                <li><a href="#lineColumns_ds">Drill and Sub-Reports</a></li>
                            </ul>
                        </li>
                        <li><a href="#lineJoins">Joins</a></li>
                        <li>
                            <a href="#lineEnums">Enumerated lists</a>
                            <ul class="nav">
                                <li><a href="#lineEnums_de">Dynamic enums</a></li>
                                <li><a href="#lineEnums_dd">Dynamic display</a></li>
                            </ul>
                        </li>
                        <li>
                            <a href="#lineNoSQL">LINQ Data Sources</a>
                            <ul class="nav">
                                <li><a href="#lineNoSQL_nst">No SQL Table</a></li>
                                <li><a href="#lineNoSQL_jtl">Joins and Table Links</a></li>
                                <li><a href="#lineNoSQL_mdb">Mongo DB Support</a></li>
                            </ul>
                        </li>
                    </ul>
                    <img src="Images/Seal-Report-Logo.png" class="img-thumbnail img-rounded" style="margin-left:20px;" />
                    <p style="margin-left:20px;">
                        <strong><a href="#feed">Feed the Seal ?</a></strong><br />
                        <iframe src="https://ghbtns.com/github-btn.html?user=ariacom&repo=Seal-Report&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
                    </p>
                </nav>
            </div>
            <div class="col-md-9">
                <section class="welcome">
                    <div class="row">
                        <div class="col-md-12 left-align">
                            <h2 class="dark-text">Data Sources<hr></h2>
                            <div class="row">
                                <div class="col-md-12 full">
                                    <div>
                                        <p>
                                            A <strong>Data Source</strong> defines the database connections and description (table, catalog and joins).<br>
                                            Use the <b>Server Manager</b> to create and edit your <strong>Data Sources</strong>.<br>
                                            A <strong>Repository Data Source</strong> is stored in the <i>/Sources</i> Repository sub-folder in a XML file (*.scfx).
                                        </p>
                                    </div>
                                    <div class="bs-callout bs-callout-danger">
                                        You can also define and store a <strong>Data Source</strong> in a report with the same functionalities, however it is a good practice to use <strong>Repository Data Sources</strong> to ease the maintenance and share your configurations
                                        (<eg>e.g. if you change the display label of a column, all reports referencing the column will inherit from the modification</eg>).
                                    </div>
                                </div>
                            </div>
                            <!-- end row -->
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 text-center">
                            <div class="caption">
                                <b>Data Source Objects</b>
                            </div>
                            <img src="images/CD-Data Source.png" alt="" class="img-thumbnail img-rounded">
                            <div>
                                <ck>Check also <a href="~/Help/Index.html" target="_blank">Seal Report Library (Seal.Model namespace)</a> for more information</ck>.
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                </section>
                <section id="lineConnections" class="section">
                    <div class="row">
                        <div class="col-md-12 left-align">
                            <h2 class="dark-text">Connections <hr></h2>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div class="row">
                        <div class="col-md-12">
                            <p>
                                Setting up a connection is the first thing to do after creating a <strong>Data Source</strong>.<br />

                                A <strong>Connection</strong> defines how to connect to the database to be queried by using an OLEDB, ODBC, MS SQLServer, Mongo DB or MySQL Driver.<br />
                                A <strong>Data Source</strong> can have one to many Connections (<eg>e.g. dev, test, production, etc.</eg>).
                            </p>
                            <div class="bs-callout bs-callout-danger">
                                Make sure that your database driver is installed on the machine you are running the <b>Server Manager</b>.<br />
                            </div>
                            <p>
                                Use the <code>Database Type</code> property to define your database type. This type may be used by the engine in different ways (<eg>e.g. using Serial Date for Ms Access</eg>).<br />
                                Once the connection successfully defined, you can use the Wizard to import tables, columns and joins from the database catalog.
                            </p>
                            <div class="bs-callout bs-callout-warning">
                                <i>For specific database type, use the <code>Date Time Format</code> property to specify how the date will be formatted in the dynamic WHERE clause generated by the engine.</i>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                </section>
                <!-- end section -->
                <section id="lineTables" class="section">
                    <div class="row">
                        <div class="col-md-12 left-align">
                            <h2 class="dark-text">Tables and Columns <hr></h2>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div class="row">
                        <div class="col-md-12">
                            <h4>Tables</h4>
                            <p>
                                A table is defined either by its <code>Name</code> or  by a <code>SQL Statement</code> and <code>Table alias</code> (<eg>e.g. 'Orders' or '(select * from Orders) OrdersAlias'</eg>).<br />
                                Table columns can be dynamically populated using the database catalog.
                            </p>
                            <div class="bs-callout bs-callout-warning">
                                Once columns are created, you can set the <code>Dynamic Columns</code> property to <b>false</b> to rework your column definitions.
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineTables_pps" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Pre and Post SQL Statement</h4>
                            <p>
                                A table can also have a <code>Pre SQL Statement</code> (<code>Post SQL Statement</code>) that is executed before (and after) the select statement is performed for a report model.<br />
                                It occurs only if the report model involves the table.<br />
                                These statements can be used for different purposes: Creating/Dropping a temporary table, updating columns, etc.<br /><br />
                            </p>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineTables_wc" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Additional WHERE Clause</h4>
                            <p>
                                An <code>Additional WHERE Clause</code> can also be defined to filter at run-time the records of the table.<br />
                                This feature may be interesting to apply filter based on the person logged (<eg>e.g. a salesman can see only the orders he made</eg>).<br />
                                <ck>Check <a href="~/Recipes#lineDynamicSecurity">Filtering records based on security</a> for more information</ck>.<br />
                                <br />
                            </p>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineTables_cr" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Common restrictions and values</h4>
                            <p>
                                All SQL involved in the table definition (<code>Name</code>, <code>SQL Statement</code>, <code>Pre SQL Statement</code>, etc.) can contain the keywords <b>'{CommonRestriction_&#60;RestrictionName&#62;}'</b> or <b>'{CommonValue_&#60;RestrictionName&#62;}'</b> where <b>&#60;RestrictionName&#62;</b>
                                is the name of the restriction.<br />
                                Once defined, the common restriction can be defined in the models involving the table using the <code>Common Restrictions</code> property of the <a href="~/Reports#lineModels_def">model definition</a>.<br />
                                <strong>Common restrictions</strong> are used to inject values prompted by the end-user in the form 'ColumnName=Value' or 'ValueOnly' if the restriction has the operator ValueOnly.<br />
                                <ck>Check <a href="~/Reports#lineModels_restr">Restrictions</a> for more information</ck>.<br />
                            </p>
                            <div class="bs-callout bs-callout-warning">
                                Use common restrictions if you have performance issue and you want to filter a huge table defined with sub-select.<br />
                                Common restriction can also be used to pass parameters to stored procedures.
                            </div>
                            <div class="bs-callout bs-callout-info">
                                Note that the same Common Restriction or Value can be used several times.<br />
                                e.g. the following SQL can be used to define a table or a SQL Model:
                                <pre class="brush: sql;">
                                SELECT 'Type1' type, sum(aColumn1) amount FROM aTableName1 WHERE subType in (3,4) and {CommonRestriction_Date}
                                UNION
                                SELECT 'Type2' type, sum(aColumn2) FROM aTableName2 WHERE {CommonRestriction_Date}
                                UNION
                                SELECT 'Type3' type, sum(aColumn3) FROM aTableName3 WHERE {CommonRestriction_Date}
                            </pre>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                </section>
                <!-- end section -->
                <section id="lineColumns" class="section">
                    <div class="row">
                        <div class="col-md-12">
                            <h4>Columns</h4>
                            <p>
                                A <strong>column</strong> is defined with its SQL (<code>Name</code>), its <code>Data type</code> and how it is display in the <b>Report Designer</b> (<code>Display name</code> and <code>Category Name</code> properties) and in the report result (<code>Format</code> property).<br><br>

                                In certain cases, a column can reference an enumerated list with the  <code>Enumerated List</code> property (<eg>e.g. the value 0 will be display with 'No', 1 with 'Yes'</eg>).<br>
                                <ck>Check <a href="#lineEnums">Enumerated Lists</a> for more information</ck>.
                            </p>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineColumns_ds" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Drill and Sub-Reports Navigation</h4>
                            <p>
                                Once the column is displayed in the report result, a navigation popup menu can be activated (in the table cells or in charts).<br />
                            </p>
                            <p>
                                Two types of navigation can be done:
                            </p>
                            <ul>
                                <li>
                                    <strong>Drill</strong> navigation to show the same report with another dimension (<eg>e.g. Country->Region->City, Year->Quarter->Month->Day</eg>).<br>
                                    When drilling, the same report is executed with a new restriction on parent element value, and the parent element is replaced by its child in the model definition.
                                </li>
                                <li>
                                    <strong>Sub-report</strong> navigation to view another report (<eg>e.g. from Order ID->Show a report detail on the Order</eg>).<br />
                                    A new report is then executed with the restriction on the element value.
                                </li>
                            </ul>
                            <p>
                                After a navigation has occurred, a new menu appears on the top left of the report result.
                            </p>
                            <p>
                                One to several drill children can defined using the <code>Drill Children</code> property.<br />
                                One to several sub-reports can defined using the <code>Sub-Reports</code> property.<br />

                                A sub-report file is often located in the <i>/SubReports</i> Repository sub-folder and must have a restriction defined for the column.
                            </p>
                            <div class="bs-callout bs-callout-demo">
                                <h4>Drill Element Samples</h4>
                                In the <b>Northwind</b> Data Source, select the <strong>Orders.Order Year</strong> column and check that the <code>Drill Children</code> property is set to <strong>Orders.Order Month</strong>.<br />
                                Then the hierarchy continues to <strong>Orders.Order Year->Orders.Order Month->Orders.Order ID</strong>.<br /><br />
                                A drill child is also defined for the column <strong>Products.Category->Products Name</strong>.<br />
                            </div>
                            <div class="bs-callout bs-callout-demo">
                                <h4>Sub-Report Elements Samples</h4>
                                In the <b>Northwind</b> Data Source, select the <strong>Orders.Order ID</strong> column and check that the <code>Sub Reports</code> property is pointing to the <b>SubReports\Order Detail.srex</b> report.<br><br />
                                A sub-report is also defined for the columns <strong>Customers.Customer</strong>, <strong>Employees.Employee Name</strong>, <strong>Products.Product Name</strong>.
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                </section>
                <section id="lineJoins" class="section">
                    <div class="row">
                        <div class="col-md-12 left-align">
                            <h2 class="dark-text">Joins <hr></h2>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div class="row">
                        <div class="col-md-12">
                            <p>
                                A <strong>join</strong> defines how 2 tables can be joined through a <code>SQL clause</code>.<br />
                                Joins are used by the Seal engine to build a select involving several tables (<eg>e.g. 'FROM Table1 INNER JOIN Table2 ON'</eg>).
                            </p>
                            <div class="bs-callout bs-callout-info">
                                When joining two tables, the <code>SQL clause</code> is used by the Seal engine without any transformation, thus it is recommended to use the table names or alias before the column.
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                </section>
                <!-- end section -->
                <section id="lineEnums" class="section">
                    <div class="row">
                        <div class="col-md-12 left-align">
                            <h2 class="dark-text">Enumerated lists <hr></h2>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div class="row">
                        <div class="col-md-12">
                            <p>
                                <strong>Enumerated lists</strong> are mainly used to allow the end-user to select a value from a combo-box when a restriction is prompted.<br />
                                An enum has an <code>Identifier</code> and an optional display <code>Value</code> (<eg>e.g. 0 = False, 1 = True</eg>).<br />
                                In addition, an enum can have a specific <code>CSS Class</code>, <code>CSS Style</code> to change the display of the result cell in the report result, and <code>Restriction Value</code> to change the display value when the enum is used for a restriction.<br />

                                If the display value is different from the identifier, using an enumerated list for a column can avoid a table join (<eg>e.g. if my enum contains CategoryID and CategoryName, the join with a table Category is not necessary</eg>).<br />
                                Using enumerated lists allows also to translate the display value in different languages (<eg>e.g. 0 gives 'Yes' or 'Oui' according to the user locale</eg>).<br />
                                Finally, you can define custom sort that you could not do in SQL (<eg>e.g. having a sort by month with the names like 'January', 'February', etc. but the identifier is the month number</eg>).<br />
                                <br />
                                By default, an enumerated list is static, just edit the values using the Collection Editor.<br />
                            </p>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineEnums_de" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Dynamic enums</h4>
                            <p>
                                <strong>Enumerated list</strong> can be also loaded from the database using <code>SQL Select Statement</code> and/or a <code>Razor Script</code>.<br />
                                The select statement can have up to 5 columns to define dynamic enumerated list.<br />
                                <ul>
                                    <li>the first column is used for the identifier</li>
                                    <li>the second optional column is the display value shown in the table result</li>
                                    <li>the third optional column is the display value shown in the restriction list</li>
                                    <li>the fourth optional column defines a custom CSS Style applied to the result cell</li>
                                    <li>the fifth optional column defines a custom CSS Class applied to the result cell</li>
                                </ul>
                                The <code>Script</code> can be used to create or modify the <strong>Enumerated list</strong> values.<br />
                                Changing the CSS style or class can be useful to change the color depending on the value (<eg>e.g. green if OK, red if KO</eg>).<br /><br />
                            </p>
                            <div class="bs-callout bs-callout-danger">
                                <h4>Performances</h4>
                                As building the enum list can be time consuming, it is a good practice to schedule a task to update enum values every morning.<br />
                                Setting <code>List is refreshed upon the database connection</code> to <b>true</b> means the list is always queried when the report is executed. This can be useful if the list depends on the user connected but can be also time consuming.
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineEnums_dd" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Dynamic display for prompted restrictions</h4>
                            <p>
                                For huge list of values or for list having dependencies with other enums, a dynamic display is possible to allow the server to query live the database before showing the values to the user.<br />
                                In this case, you must define the <code>SQL Select Statement for prompted restriction</code> property.<br />
                                This dedicated SQL can contain the keyword <b>'{EnumFilter}'</b> to specify the text typed by the user and/or <b>'{EnumValues_&#60;OtherEnumName&#62;}'</b> to use the values checked for another enumerated list.
                            </p>
                            <div class="bs-callout bs-callout-demo">
                                <h4>Filter on the name of the product</h4>
                                <pre class="brush: sql">
                                    SELECT DISTINCT ProductID, ProductName FROM Products 
                                    WHERE ProductName LIKE '%{EnumFilter}%' 
                                    ORDER BY 2
                                </pre>
                            </div>

                            <div class="bs-callout bs-callout-demo">
                                <h4>List of customers of selected countries</h4>
                                Build the list of customers only when countries are selected first.<br>This works only if both Customers and Countries are restrictions in the report.
                                <pre class="brush: sql">
                                SELECT DISTINCT City FROM Customers
                                WHERE Country in ({EnumValues_Country})
                                ORDER BY 1
                                </pre>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div class="bs-callout bs-callout-demo">
                        <h4>Dynamic Display Samples</h4>
                        <a class="btn btn-primary live-sample">Live Sample: 09-Enumerated List - Dynamic Display</a><br />
                        This report shows how the 'Product Name' prompted list depends on the choice of a 'Product Category'.<br />
                        The report contains also a custom enumerated list named to search the product name with characters.
                        <a class="btn btn-primary live-sample">Live Sample: 02-LINQ/210-Enumerated List LINQ - Dynamic Display</a><br />
                        This report contains two <b>Enumerated Lists</b> defined by <code>Scripts</code> with a <b>LINQ</b> Source.
                    </div>
                </section>
                <!-- end section -->
                <section id="lineNoSQL" class="section">
                    <div class="row">
                        <div class="col-md-12 left-align">
                            <h2 class="dark-text">LINQ Data Sources <hr></h2>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div class="row">
                        <div class="col-md-12">
                            <p>
                                A <strong>LINQ Data Source</strong> can provide data that cannot be queried from a SQL database engine.<br />
                                The Seal engine generates dynamically a <b>LINQ query</b> including the elements selected, the restrictions and the joins involved.<br />
                                Depending on the data fetched, it may require advanced C#/.Net skills.
                            </p>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineNoSQL_nst" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>No SQL Table</h4>
                            <p>
                                A <strong>LINQ Data Source</strong> contains <b>No SQL Tables</b> based on the templates defined in the repository.<br />
                                A <b>No SQL table</b> is then defined with a <code>Definition Script</code> to insert the columns in the main table and the <code>Load script</code> to load the data.<br><br />
                                Once the table is defined, the columns can be used in report models as normal columns coming from a database.<br />
                                The scripts manage a <b>.Net DataTable Object</b>.<br />
                                Restrictions are handled in the server by using filter capacities of the DataTable.
                            </p>
                            <div class="bs-callout bs-callout-warning">
                                <h4>Table Templates</h4>
                                <i>Mongo DB, Adomd OLAP MDX, CSV, Excel, HTTPCLient JSON, XML, RSS</i> are template files defined in <i>/Sources/TableTemplates</i> Repository sub-folder.<br />
                                By default use the <i>Generic</i> template.<br />
                                Just add your own template in this folder.
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineNoSQL_jtl" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Joins and Table Links</h4>
                            <p>
                                Like in SQL, <b>Joins</b> can be defined between tables using a dedicated <code>Join clause</code> coded in C#.<br />
                                This clause will be used by the engine to generate the LINQ query when several tables are involved.
                            </p>
                            <p>
                                In addition to <b>No SQL Tables</b>, a <strong>LINQ Data Source</strong> can have <b>Table Links</b> that reference tables defined in other <b>SQL or LINQ Data Sources</b> installed in the Repository.<br />
                                <b>Joins</b> can then be defined using the <b>Tables</b> referenced by the <b>Table Link</b>.
                            </p>
                            <div class="bs-callout bs-callout-info">
                                Defining <b>Table Links</b> and <b>Joins</b> allow to join different <b>Data Sources</b> (<eg>e.g. Performing a report that shows data from a SQL database and an Excel sheet</eg>).
                            </div>
                            <p>
                                In the LINQ Query, elements defined in a <b>No SQL table</b> are named with the <b>Table Name</b> and the <b>Column Name</b> (<eg>e.g. for the objective column of Excel Employee Objective: <i>ExcelEmployeeObjective["objective"]</i></eg>), and elements defined in a <b>Table Link</b> are named using the <b>Data Source Name</b> and the original <b>Column Name</b> (<eg>e.g. for the LastName column of Employees: <i>Northwind["Employees.LastName"]</i></eg>).
                            </p>
                            <div class="bs-callout bs-callout-demo">
                                <h4>Join Script Sample</h4>
                                Example of a <code>Join clause</code> between <b>Northwind</b> tables and an <b>Excel Sheet</b> table.
                                <pre class="brush: csharp">new {x1=Helper.ToString(Northwind["Employees.LastName"]), x2=((DateTime)Northwind["DATETIME2FROMPARTS(year(Orders.OrderDate),1,1,0,0,0,0,0)"]).Year}
equals 
new {x1=Helper.ToString(ExcelEmployeeObjective["employee"]), x2=Int32.Parse(ExcelEmployeeObjective["year"].ToString()) }
                    </pre>

                            </div>
                            <div class="bs-callout bs-callout-demo">
                                <h4>LINQ Source Samples</h4>
                                <a class="btn btn-primary live-sample">Live Sample: 02-LINQ/200-LINQ Source - Excel and CSV Sources</a><br />
                                This report one new LINQ SQL Source with 2 No SQL Tables: One loaded from an Excel Sheet, one from a CSV file.<br /><br />
                                <a class="btn btn-primary">Repository Data Source Sample: LINQ Sources</a><br />
                                This source contains several <b>No SQL Tables</b> based on the <b>Table Templates</b> available.<br /><br />
                                The table <b>XML RSS News</b> shows how to read RSS BBC Feeds to fill the DataTable.<br />
                                <code>Definition Script</code> property of the table.
                                <pre class="brush: csharp">@@using System.Data
@@{
    MetaTable metaTable = Model;
    DataTable table = new DataTable();
	//Define the table columns 
	table.Columns.Add(new DataColumn("Id", typeof(string)));
	table.Columns.Add(new DataColumn("Date", typeof(DateTime)));
	table.Columns.Add(new DataColumn("Title", typeof(string)));
	table.Columns.Add(new DataColumn("Summary", typeof(string)));
	table.Columns.Add(new DataColumn("Link", typeof(string)));
	table.Columns.Add(new DataColumn("Categories", typeof(string)));
	table.Columns.Add(new DataColumn("TitleWithLink", typeof(string)));
	metaTable.NoSQLTable = table;
}
</pre><br />

                                <code>Load script</code> property of the table.
                                <pre class="brush: csharp">@@using System.Data
@@using System.Text
@@using System.Collections
@@using System.Web
@@using System.Xml
@@using System.ServiceModel.Syndication
@@{
    //Just feed the table from the RSS data
    MetaTable metaTable = Model;
    DataTable table = metaTable.NoSQLTable;

	var url = metaTable.GetValue("rss_url");
    metaTable.LogMessage("Loading RSS feed from {0}", url);
	var reader = XmlReader.Create(url);
	var feed = SyndicationFeed.Load(reader);
    foreach (var item in feed.Items)
    {
        string link = item.Links.Count > 0 ? item.Links[0].Uri.AbsoluteUri : "";
        string categories = "";
        foreach (var category in item.Categories)
        {
            categories += category.Name + ";";
        }
        string titleWithLink = string.Format("<a href='{0}' target=_blank>{1}</a>", link, HttpUtility.HtmlEncode(item.Title.Text));
        //Values must match the table definition
        table.Rows.Add(item.Id, item.PublishDate.DateTime, item.Title.Text, item.Summary.Text, link, categories, titleWithLink);
    }
    metaTable.LogMessage("{0} record(s) loaded", table.Rows.Count);
}
                    </pre>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                    <div id="lineNoSQL_mdb" class="row" style="padding-top:35px">
                        <div class="col-md-12">
                            <h4>Mongo DB Support</h4>
                            <p>
                                A dedicated <strong>Connection Type</strong> and <code>Connection String</code> has been implemented to handle queries on Mongo DB.
                            </p>
                            <p>
                                Once the connection setup in the <b>LINQ Data Source</b>, Mongo DB tables can be defined using the <b>Mongo DB</b> Table template.<br />
                                A collection name and several parameters (like the name of an array to unwind) allow to define the table.
                            </p>
                            <p>
                                If a <b>Mongo DB</b> table is involved in a model, the report engine generates automatically the <code>Mongo DB Stages Script</code> of the table to apply elements and restrictions at the database server level.<br />
                                This script will be executed before the <code>Load Script</code> and can be customized if the flag <code>Generate Mongo DB Stages</code> is set to <b>False</b>.
                            </p>
                            <div class="bs-callout bs-callout-danger">
                                Use a Wizard to start: Right click on the <b>Tables</b> and select the <strong>'Add Tables from Mongo DB Catalog'</strong> menu to browse and add tables using the current connection.
                            </div>
                            <div class="bs-callout bs-callout-demo">
                                <h4>Mongo DB Samples</h4>
                                <a class="btn btn-primary live-sample">Live Sample: 02-LINQ/220-Mongo DB - Customer sales per year</a><br />
                                <a class="btn btn-primary live-sample">Live Sample: 02-LINQ/221-Mongo DB - Customer sales detail</a><br />
                                <a class="btn btn-primary live-sample">Live Sample: 02-LINQ/222-Mongo DB - Movies search</a><br />
                                <a class="btn btn-primary live-sample">Live Sample: 02-LINQ/223-Mongo DB - Movies - Northwind</a><br />
                                These reports demonstrate how to query and aggregate several tables.<br /><br />
                                <a class="btn btn-primary">Repository Data Source Sample: Mongo DB</a><br />
                                This source contains several <b>Mongo DB Tables</b> based on the demonstration database.<br /><br />
                                The table <b>movies</b> defines the <b>sample_mflix.movies</b> collection of the database.<br />
                                The related table <b>movies_cast</b> is defined to show the <b>cast</b> array of the collection.<br />
                                A Join clause has been defined between the 2 tables:
                                <pre class="brush: csharp">Helper.ToString(movies["_id"]) equals Helper.ToString(moviescasts["_id"])
                    </pre>
                            </div>
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->
                </section>
                <!-- end section -->

            </div>
            <!-- // end .col -->
        </div>
    </div>
    <!-- // end container -->
</div>
<!-- end wrapper -->

@section scripts {
    <script>
        $(document).ready(function () {
            $("#sources_nav").addClass("active");
        });
    </script>
}
